import java.io.*;
import java.util.*;
public class test{
    public static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read in = new Read();
    public static boolean[] count1 = new boolean[10];
    public static boolean[][] count2 = new boolean[4][4];
    public static int[][] arr = new int[4][4];
    public static int[][] nums = new int[4][4];
    public static HashSet<int[][]> set = new HashSet<>();
    public static int num;
    // 蓝桥杯 九宫幻方(⭐⭐⭐⭐)
    public static void main(String[] args) throws IOException{
        int n = 0;
        for(int i = 1;i <= 3;i++){
            for(int j = 1;j <= 3;j++){
                arr[i][j] = in.nextInt();
                if(arr[i][j] != 0){
                    n++;
                    count1[arr[i][j]] = true;
                    count2[i][j] = true;
                }
            }
        }
        dfs(n);
        if(num != 1) {
            System.out.println("Too Many");
            return;
        }
        for(int i = 1;i <= 3;i++){
            for(int j = 1;j <= 3;j++){
                System.out.print(nums[i][j] + " ");
            }
            System.out.println();
        }
    }
    public static void dfs(int n){
        if(num > 1){
            return;
        }
        if(n == 9){
            if(flg()) {
                boolean tr = false;
                for(int i = 1;i <= 3;i++){
                    if(!Arrays.equals(arr[i],nums[i])){
                        tr = true;
                    }
                }
                if(!tr) return;
                num++;
                for(int i = 1;i <= 3;i++){
                    for(int j = 1;j <= 3;j++){
                        nums[i][j] = arr[i][j];
                    }
                }
            }
            return;
        }
        for(int i = 1;i <= 3;i++) {
            for(int j = 1;j <= 3;j++) {
                if(count2[i][j]) continue;
                count2[i][j] = true;
                for (int k = 1; k <= 9; k++) {
                    if(count1[k]) continue;
                    count1[k] = true;
                    arr[i][j] = k;
                    dfs(n + 1);
                    count1[k] = false;
                    arr[i][j] = 0;
                }
                count2[i][j] = false;
            }
        }
    }
    public static boolean flg(){
        int[] n1 = new int[4];
        int[] n2 = new int[4];
        for(int i = 1;i <= 3;i++){
            for(int j = 1;j <= 3;j++){
                n1[i] += arr[i][j];
                n2[j] += arr[i][j];
            }
        }
        if(n1[1] != n1[2] || n1[2] != n1[3]){
            return false;
        }
        if(n2[1] != n2[2] || n2[2] != n2[3]){
            return false;
        }
        int sum1 = arr[1][1] + arr[2][2] + arr[3][3];
        int sum2 = arr[1][3] + arr[2][2] + arr[3][1];
        if(sum1 != sum2){
            return false;
        }
        return true;
    }
    // 蓝桥杯 42点问题(⭐⭐)
    public static ArrayList<Integer> list;
    public static void main2(String[] args) throws IOException{
        list = new ArrayList<>();
        for(int i = 0;i < 6;i++){
            char c = in.next().charAt(0);
            int num = c - '0';
            if(c == 'J'){
                num = 10;
            }else if(c == 'Q'){
                num = 11;
            }else if(c == 'K'){
                num = 12;
            }else if(c == 'A'){
                num = 1;
            }
            if(i == 0){
                list.add(num);
            }else {
                dfs(num,i);
            }
        }
        if(list.contains(42)) System.out.println("YES");
        else System.out.println("NO");
    }
    public static void dfs(int x,int n){
        int len = list.size();
        for(int i = 0;i < len;i++){
            int n1 = list.get(i) + x;
            int n2 = list.get(i) - x;
            int n3 = list.get(i) * x;
            int n4 = list.get(i) / x;
            list.remove(i);
            list.add(n1);list.add(n2);list.add(n3);list.add(n4);
        }
    }
    // 蓝桥杯 路径之谜(⭐⭐⭐)
    public static int n;//代表城堡地面的面积(n*n)
    public static int[] xn;// 用于代表用x轴对应的箭靶
    public static int[] yn;// 用于代表用y轴对应的箭靶
    public static int[] dx = {1,-1,0,0};
    public static int[] dy = {0,0,1,-1};
    //用于记录每一条可能的路径
    public static ArrayList<Integer> path;
    //public static ArrayList<Integer> list;
    public static boolean[][] count;
    //public static int num;
    public static void main3(String[] args) throws IOException {
        n = in.nextInt();
        xn = new int[n + 1];
        yn = new int[n + 1];
        count = new boolean[n + 1][n + 1];
        path = new ArrayList<>();
        for(int i = 1;i <= n;i++){
            yn[i] = in.nextInt();
        }
        for(int i = 1;i <= n;i++){
            xn[i] = in.nextInt();
        }
        path.add(number(1,1));
        count[1][1] = true;
        xn[1]--;
        yn[1]--;
        dfs1(1,1);
        for(int i = 0;i < list.size();i++){
            System.out.print(list.get(i) + " ");
        }
    }
    // index:路径号
    public static void dfs1(int x,int y){
        if(num == 1){
            return;
        }
        //走到了出口,进行检查
        if(x == n && y == n){
            for(int i = 1;i <= n;i++){
                if(xn[i] != 0 || yn[i] != 0) return;
            }
            num++;
            list = new ArrayList<>(path);
            return;
        }
        for(int i = 0;i < 4;i++) {
            int xx = x + dx[i];
            int yy = y + dy[i];
            // 1. 不越界
            // 2. 没走过
            if (xx > 0 && xx <= n && yy > 0 && yy <= n && !count[xx][yy]) {
                // 3. 靶子不能再射,返回
                if(xn[xx] < 0 || yn[yy] < 0) return;
                xn[xx]--;
                yn[yy]--;
                count[xx][yy] = true;
                path.add(number(xx, yy));
                dfs1(xx, yy);
                xn[xx]++;
                yn[yy]++;
                count[xx][yy] = false;
                path.remove(path.size() - 1);
            }
        }
    }
    public static int number(int x,int y){
        return (x - 1) * n + (y - 1);
    }
}
class Read{
    StringTokenizer st = new StringTokenizer("");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String next() throws IOException{
        while(!st.hasMoreTokens()){
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
    long nextLong() throws IOException{
        return Long.parseLong(next());
    }
    double nextDouble() throws IOException{
        return Double.parseDouble(next());
    }
}